﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cvk.Banner;

namespace BatDongSan.Modules
{
    public partial class Advertisement : System.Web.UI.UserControl
    {
        public int _width, _height;
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// Load Quảng cáo theo chiều dọc, vừa hình ảnh vừa flash
        /// </summary>
        /// <param name="idCat">Mã vị trí</param>
        /// <param name="width">Kích thước vị trí đó</param>
        public void LoadBannerList(int idCat, int top, string width, string padding_top)
        {
            try
            {
                Cvk_BannerCategory info = BannerBll.claCategory.GetInfo(idCat, Utility.strConnect);
                _width = Convert.ToInt32(info.Width);
                _height = Convert.ToInt32(info.Height);

                List<Cvk_Banner> list = BannerBll.claBanner.GetList(idCat, true, top, Utility.strConnect);
                if (list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        ltrBanner.Text += "<div style=\"padding-top:" + padding_top + ";\"><div class=\"border\"><div style=\"width: " + width + "px;\">";
                        if (list[i].FileType == 1)
                        {

                            ltrBanner.Text += "<a href=\"" + list[0].Link + "\" target=\"_blank\"><img id=\"" + list[i].BannerId + "\" style=\"border-width: 0px; width:" + width + "px;\" src=\"/Uploads/Banner/Img/" + list[i].FileName + "\"/></a>";

                        }
                        else if (list[i].FileType == 2)
                        {
                            _width = Convert.ToInt32(list[i].Width);
                            _height = Convert.ToInt32(list[i].Height);
                            ltrBanner.Text += "<object id=\"kpop_music-" + list[i].BannerId + "\" width=\"" + _width + "\" height=\"" + _height + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\"> " +
                                                " <param name=\"allowScriptAccess\" value=\"sameDomain\"/> " +
                                                " <param name=\"movie\" value=\"/Uploads/Banner/flash/" + list[i].FileName + "\"/>" +
                                                " <param name=\"quality\" value=\"high\"/>" +
                                                " <param name=\"wmode\" value=\"transparent\"/>" +
                                                " <embed width=\"" + _width + "\" height=\"" + _height + "\" src=\"/Uploads/Banner/flash/" + list[i].FileName + "\" allowscriptaccess=\"sameDomain\" wmode=\"transparent\" quality=\"high\" swliveconnect=\"true\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" name=\"cvkvietnam.com\"/>" +
                                            " </object>";
                        }
                        ltrBanner.Text += "</div></div></div>";
                    }
                }
            }
            catch { }
        }
    }
}